<?php
/**
 * mvcgen
 * - The entrance for codegen
 * @author Do Truong Giang
 */
include_once("../conf/config.php");
define(OUTPUT_FOLDER_UI, DOCUMENT_ROOT . "/lib/ui");
define(OUTPUT_FOLDER_DB, DOCUMENT_ROOT . "/lib/dao");
include_once(DOCUMENT_ROOT . "/codegen/src/DbReader.class.php");
include_once(DOCUMENT_ROOT . "/codegen/src/UiReader.class.php");

// Read the config.xml file to get db files and ui files
$xml = new DomDocument();
$xml->load("conf/config.xml");
foreach ($xml->getElementsByTagName("db-file") as $dbNode) {
	$dbFile = "data/" . $dbNode->getAttribute("path");
	// Extract info of table to file xml && Create Db model
	$dbReader = new DbReader($dbFile);
	$dbReader->generateCode();
}
foreach ($xml->getElementsByTagName("ui-file") as $uiNode) {
	$uiFile = "data/" . $uiNode->getAttribute("path");
	// Create View
	$uiReader = new UiReader($uiFile);
	$uiReader->generateCode();
}
?>